import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class 滴滴第2题 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextLine()) {
            int rows = Integer.parseInt(sc.nextLine().trim());
            int cols = Integer.parseInt(sc.nextLine().trim());
            int cnt = Integer.parseInt(sc.nextLine().trim());

            Map<Long, UnionTree> posMap = new HashMap<>();
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < cnt; i++) {
                //加入陆地
                String[] strings = sc.nextLine().split(" ");
                int x = Integer.parseInt(strings[0]);
                int y = Integer.parseInt(strings[1]);
                //判断是不是岛屿
                if (!(x >= rows || y >= cols || x < 0 || y < 0)) {
                    UnionTree node = new UnionTree(x, y);
                    posMap.put(node.id, node);
                    node.join(posMap);
                }
                //遍地得出岛屿
                int islands = 0;
                for (UnionTree tree : posMap.values()) {
                    if (tree.parent == tree) {
                        islands++;
                    }
                }
                sb.append(islands).append(' ');
            }

            //去掉最后的空行
            if (sb.length() > 0) {
                sb.setLength(sb.length() - 1);
            }
            System.out.println(sb.toString());
        }

    }

    private static final class UnionTree {
        UnionTree parent;
        final int x, y;
        final long id;

        //构造
        UnionTree(int x, int y) {
            this.x = x;
            this.y = y;
            this.id = (long) x << 32 | (long) y;
            this.parent = this;
        }

        //发现
        UnionTree find() {
            UnionTree t = this;
            while (t.parent != t) {
                t = t.parent;
            }
            return t;
        }

        //加入函数1
        private void join(Map<Long, UnionTree> map) {
            join(map, id + 1);
            join(map, id - 1);
            join(map, id + 0x100000000L);
            join(map, id - 0x100000000L);
        }

        //加入函数2
        private void join(Map<Long, UnionTree> map, long id) {
            UnionTree tree = map.get(id);
            if (tree != null) {
                tree.find().parent = this;
            }
        }

    }
}




